<?php
/**
 * @author: arian
 * @email: arian@dwebsite.com
 * @on: 06/23/08
 *
 */ 
 Zend_Loader::loadClass("BaseDBRows");
 Zend_Loader::loadClass("UserModulePermission");
 Zend_Loader::loadClass("Module");
 class UserModulePermissions extends BaseDBRows
 {
 	protected function setUp()
 	{
 		$this->_tableName = UserModulePermission::_tablename;
 	}
	
	public function deletePermissionsWithUserID($id)
	{
		$db = DBCon::instance();
		$db->executeCommand("DELETE FROM ". UserModulePermission::_tablename ." WHERE user_id = ". $id);
	}
	
	public function deletePermissionsUserIDParentmoduleId($id,$parentModuleId)
	{
		$db = DBCon::instance();
		$db->executeCommand("DELETE FROM ". UserModulePermission::_tablename ." WHERE user_id = ". $id .
					" AND module_id in (select m.id from " . Module::_tablename . " as m  where m.parent_module_id = " . $parentModuleId . ") " );
	}
	
	public function loadUserModulePermissions($userId = 0 ){
		return $this->loadWhere(" user_id = ". $userId );
	}
 }
?>